<div class="dialog-header">
  <div class="folder-dialog-info fw-600 fs-17 text-dark">
    生成可共享链接
  </div>
  <div class="close-icon" (click)="closeDialog()">
    <span class="material-icons cursor-pointer">
      close
    </span>
  </div>
</div>
<div class="d-content" [formGroup]="documentLinkForm">
  <div *ngIf="isEditMode" class="mb-3">
    <div class="row align-items-center justify-content-between">
      <div class="col-md col">
        <label for="link" class="mb-0">链接共享已打开</label>
      </div>
      <div class="col-auto col-m-auto">
        <button (click)="deleteDocumentLink()" mat-icon-button class="mr-1 text-danger">
          <mat-icon class="text-danger">delete</mat-icon>
        </button>
        <button mat-icon-button (click)="openLinkSettings()" class="text-main">
          <mat-icon class="text-main">settings</mat-icon>
        </button>
      </div>
    </div>
    <div class="row mt-2">
      <div class="col-md-12 input-group">
        <input formControlName="linkCode" type="text" id="link" class="form-control">
        <div matTooltip="Copy" [cdkCopyToClipboard]="documentLinkForm.get('linkCode').value" class="input-group-append"
          role="button">
          <span class=" input-group-text bg-main text-white">
            拷贝
          </span>
        </div>
      </div>
    </div>
  </div>
  <div *ngIf="!isEditMode || isResetLink" class="card mb-2">
    <div class="card-body">
      <section class="example-section">
        <span>链接过期时间:</span>
        <p>
          <mat-checkbox color="primary" formControlName="isLinkExpiryTime">链接是否有效期限:</mat-checkbox>
        </p>
        <ng-container *ngIf="documentLinkForm.get('isLinkExpiryTime').value">
          <!-- <mat-label>Choose a date</mat-label> -->
          <div class="input-group mb-3">
            <input class="form-control" [owlDateTimeTrigger]="dt2" [min]="minDate" formControlName="linkExpiryTime"
              [owlDateTime]="dt2" placeholder="Choose a date">
            <div class="input-group-append">
              <span class="input-group-text material-icons-outlined" [owlDateTimeTrigger]="dt2">
                event
              </span>
            </div>
          </div>
          <owl-date-time #dt2></owl-date-time>

          <!-- <input [min]="minDate" autocomplete="new-date" matInput [matDatepicker]="picker"
            formControlName="linkExpiryTime">
          <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
          <mat-datepicker #picker></mat-datepicker> -->
        </ng-container>
        <div class="text-danger"
          *ngIf="documentLinkForm.get('isLinkExpiryTime').touched && documentLinkForm.hasError('linkExpiryTimeValidator')">
          有效期是必需的.
        </div>
      </section>
      <hr>
      <section>
        <span>密码保护:</span>
        <p>
          <mat-checkbox color="primary" formControlName="isPassword">下载文件时口令密码</mat-checkbox>
        </p>
        <input *ngIf="documentLinkForm.get('isPassword').value" autocomplete="new-password" type="password"
          class="form-control" formControlName="password">
        <div class="text-danger"
          *ngIf="documentLinkForm.get('isPassword').touched && documentLinkForm.hasError('passwordValidator')">
          密码不能为空.
        </div>
      </section>
      <hr>
      <section>
        <span>允许下载</span>
        <p>
          <mat-checkbox formControlName="isAllowDownload" color="primary">有链接的用户是否下载下载此项目
          </mat-checkbox>
        </p>
      </section>
    </div>
  </div>
  <button type="submit" (click)="createLink()" *ngIf="!isEditMode" class="btn btn-primary">创建链接</button>
  <button type="submit" (click)="createLink()" *ngIf="isEditMode && isResetLink" class="btn btn-primary">更新链接</button>
</div>
<div class="loading-shade" *ngIf="isLoading">
  <mat-spinner></mat-spinner>
</div>
